package com.moyun.common.mapstruct;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

/**
 * @ClassName CarMapper
 * @Description 定义一个映射器接口，该接口声明任何所需的映射方法。在编译过程中，MapStruct 会生成这个接口的实现。
 * 官网: https://mapstruct.org/documentation/stable/reference/html/
 * @Author yangboxuan
 * @Date 2022/6/19 0:29
 */
@Mapper(componentModel = "spring")
public interface CarMapper {

    /**
     * 相同属性名会自动映射
     * 不同属性之间的映射需要使用 @Mapping(target = "xxx", source = "xxx") 注解来关联
     */
    @Mapping(target = "maxCarSpeed", source = "make")
    @Mapping(target = "seatCount", source = "numberOfSeats")
    CarDTO carToCarDto(Car car);

}